package com.ruoyi.smart.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.smart.domain.SmartQualityForm;
import com.ruoyi.smart.service.ISmartQualityFormService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 质检报告单默认值Controller
 * 
 * @author minwei
 * @date 2023-03-12
 */
@RestController
@RequestMapping("/smart/qualityform")
public class SmartQualityFormController extends BaseController
{
    @Autowired
    private ISmartQualityFormService smartQualityFormService;

    /**
     * 查询质检报告单默认值列表
     */
    @PreAuthorize("@ss.hasPermi('smart:qualityform:list')")
    @GetMapping("/list")
    public TableDataInfo list(SmartQualityForm smartQualityForm)
    {
        startPage();
        List<SmartQualityForm> list = smartQualityFormService.selectSmartQualityFormList(smartQualityForm);
        return getDataTable(list);
    }

    /**
     * 导出质检报告单默认值列表
     */
    @PreAuthorize("@ss.hasPermi('smart:qualityform:export')")
    @Log(title = "质检报告单默认值", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SmartQualityForm smartQualityForm)
    {
        List<SmartQualityForm> list = smartQualityFormService.selectSmartQualityFormList(smartQualityForm);
        ExcelUtil<SmartQualityForm> util = new ExcelUtil<SmartQualityForm>(SmartQualityForm.class);
        util.exportExcel(response, list, "质检报告单默认值数据");
    }

    /**
     * 获取质检报告单默认值详细信息
     */
    @PreAuthorize("@ss.hasPermi('smart:qualityform:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(smartQualityFormService.selectSmartQualityFormById(id));
    }

    /**
     * 新增质检报告单默认值
     */
    @PreAuthorize("@ss.hasPermi('smart:qualityform:add')")
    @Log(title = "质检报告单默认值", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SmartQualityForm smartQualityForm)
    {
        return toAjax(smartQualityFormService.insertSmartQualityForm(smartQualityForm));
    }

    /**
     * 修改质检报告单默认值
     */
    @PreAuthorize("@ss.hasPermi('smart:qualityform:edit')")
    @Log(title = "质检报告单默认值", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SmartQualityForm smartQualityForm)
    {
        return toAjax(smartQualityFormService.updateSmartQualityForm(smartQualityForm));
    }

    /**
     * 删除质检报告单默认值
     */
    @PreAuthorize("@ss.hasPermi('smart:qualityform:remove')")
    @Log(title = "质检报告单默认值", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(smartQualityFormService.deleteSmartQualityFormByIds(ids));
    }
}
